package com.etogc.groupchat.find;

import android.content.Context;

import com.etogc.http.ReqDataHandler;
import com.etogc.http.ReqErrorHandler;
import com.etogc.http.VolleyHttpUtil;
import com.etogc.util.GcUrl;
import com.etogc.util.YcToastHelper;
import com.etogc.view.LoadDialog;

import org.json.JSONObject;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by ZeroVoid on 2018-3-19.
 */

public class FindHttpBiz {

    public static void getFindList(final Context ctx, final FindAdapter adapter) {
        LoadDialog.show(ctx);
        VolleyHttpUtil.getInstance().getWithCallback(GcUrl.FIND_LIST, new VolleyHttpUtil.ResponseCallBack() {
            @Override
            public void handleResponse(JSONObject response, int errCode) {
                LoadDialog.dismiss(ctx);
                boolean isSuccess = ReqErrorHandler.getInstance().isSuccess(response, true);
                if (isSuccess) {
                    List<HashMap<String, String>> list = ReqDataHandler.getList(response);
                    if (list != null) {
                        adapter.setData(list);
                    } else {
                        YcToastHelper.getInstance()._toast("收藏失败");
                    }
                }
            }
        });
    }

}
